package com.rongc.client.freight.business.mine.view.activity;

import com.rongc.client.core.utils.ActivityUtils;
import com.rongc.client.freight.R;
import com.rongc.client.freight.base.BaseActivity;
import com.rongc.client.freight.base.view.activity.CarLengthActivity;
import com.rongc.client.freight.base.view.activity.CarModeActivity;
import com.rongc.client.freight.base.view.activity.MapGdActivity;
import com.rongc.client.freight.base.view.widget.CJRow.ARResponse;
import com.rongc.client.freight.base.view.widget.CJRow.CJRow;
import com.rongc.client.freight.base.view.widget.CJRow.CJRowListener;
import com.rongc.client.freight.base.view.widget.CJRow.CustomCJRowAdapter;
import com.rongc.client.freight.business.mine.buz.SettingBuz;
import com.rongc.client.freight.business.mine.model.CarDic;
import com.rongc.client.freight.utils.dic.IField;
import com.rongc.client.freight.utils.dic.impl.Field;
import com.rongc.client.freight.utils.dic.impl.Table;

import butterknife.Bind;

/**
 * Created by ccqx on 2017/7/17.
 */

public class SettingActivity extends BaseActivity {

    @Bind(R.id.cjrow)
    CJRow mRow;

    CustomCJRowAdapter baseAdapter;
    Table table_base;
    ARResponse response;



    @Override
    public void initView() {
        initToolbar(R.string.setting_title);
    }

    @Override
    public void initData() {
        response = SettingBuz.getMockBaseResponse();

        table_base = SettingBuz.getSettingTable(this);
        baseAdapter = new CustomCJRowAdapter(this, mRow,table_base, response);
        mRow.setAdapter(baseAdapter);


        baseAdapter.setCJRowListener(new CJRowListener() {
            @Override
            public boolean seedAction(int location, Field field, Object obj) {
                return false;
            }

            @Override
            public boolean activityAction(Field field, Object obj) {
                if("head".equals(field.getFieldName())){
                    ActivityUtils.startActivityForResult(SettingActivity.this,CarModeActivity.class, CarDic.ResultType.Model_TYPE);
                }else if("nickname".equals(field.getFieldName())){
                    ActivityUtils.startActivityForResult(SettingActivity.this,CarLengthActivity.class, CarDic.ResultType.Length_TYPE);
                }else if("password".equals(field.getFieldName())){
                    ActivityUtils.startActivity(SettingActivity.this,PasswordPayActivity.class);
                }else if("feedback".equals(field.getFieldName())){
                    ActivityUtils.startActivityForResult(SettingActivity.this,MapGdActivity.class, CarDic.ResultType.ADDRESS_TYPE);
                }else if("about".equals(field.getFieldName())){
                    ActivityUtils.startActivityForResult(SettingActivity.this,MapGdActivity.class, CarDic.ResultType.ADDRESS_TYPE);
                }
                return true;
            }

            @Override
            public boolean popupWindowAction(final IField field, Object obj) {
                return false;
            }
        });
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_setting;
    }
}
